package com.test.demo.receive;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.CountDownLatch;

/**
 * 消息接受者
 */
public class Receive {

    private static final Logger logger=LoggerFactory.getLogger(Receive.class);

    private CountDownLatch latch;

    @Autowired
    public Receive(CountDownLatch latch){
        this.latch=latch;
    }

    /**
     * 接收信息并打印
     * @param message
     */
    public void receiveMessage(String message){
        logger.info("Receive<"+message+">");
        latch.countDown();
    }
}
